home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / jedi.c < prev    next >
C/C++ Source or Header  |  2000-05-18  |  12KB  |  390 lines

  1. /****************************************************************************
  2.  
  3. Return of the Jedi
  4.  
  5. driver by Dan Boris
  6.  
  7.  
  8. Master processor
  9. 0000-07ff   R/W     Z-page Working RAM
  10. 0800-08ff   R/W     NVRAM
  11. 0C00        R       Bit 7 = Right Coin
  12.                     Bit 6 = Left Coin
  13.                     Bit 5 = Aux Coin Switch
  14.                     Bit 4 = Self Test
  15.                     Bit 3 = Spare (High)
  16.                     Bit 2 = Left thumb switch
  17.                     Bit 1 = Right thumb switch
  18. 0C01        R       Bit 7 = VBLANK
  19.                     Bit 6 = Sound CPU comm latch full flag
  20.                     Bit 5 = Sound CPU ack latch flag
  21.                     Bit 4 = Not used (High)
  22.                     Bit 3 = Not used (High)
  23.                     Bit 2 = Slam
  24.                     Bit 1 = Not used (High)
  25.                     Bit 0 = Not used (High)
  26. 1400        R       Sound CPU ack latch
  27. 1800        R       Read A/D conversion
  28. 1C00        W       Enable NVRAM
  29. 1C01        W       Disable NVRAM
  30. 1C80        W       Start A/D conversion (horizontal)
  31. 1C82        W       Start A/D conversion (vertical)
  32. 1D00        W       NVRAM store
  33. 1D80        W       Watchdog clear
  34. 1E00        W       IRQ ack
  35. 1E80        W       Left coin counter
  36. 1E81        W       Right coin counter
  37. 1E82        W       LED 1(not used)
  38. 1E83        W       LED 2(not used)
  39. 1E84        W       Alphanumeric ROM bank select
  40. 1E85        W       Not used
  41. 1E86        W       Sound CPU reset
  42. 1E87        W       Video off
  43. 1F00        W       Sound CPU comm latch
  44. 1F80        W       Bit 0..2: Program ROM bank select
  45. 2000-23FF   R/W     Scrolling playfield (low)
  46. 2400-27FF   R/W     Scrolling playfield (high)
  47. 2800-2BFF   R/W     Color RAM (low)
  48. 2C00-2FFF   R/W     Color RAM (high)
  49. 3000-37BF   R/W     Alphanumeric RAM
  50.  
  51. 37C0-37EF   R/W     Motion object picture
  52. 3800-382F   R/W     Bit 6,2,1 = Motion object picture bank select
  53.                     Bit 5 = Motion object vertical reflect
  54.                     Bit 4 = Motion object horizontal reflect
  55.                     Bit 3 = Motion object 32 pixels tall
  56.                     Bit 0 = Motion object horizontal position (D8)
  57. 3840-386F   R/W     Motion object vertical position
  58. 38C0-38EF   R/W     Motion object horizontal position (D7-D0)
  59. 3C00-3C01   W       Scrolling playfield vertical position
  60. 3D00-3D01   W       Scrolling playfield horizontal position
  61. 3E00-3FFF   W       PIXI graphics expander RAM
  62. 4000-7FFF   R       Banked program ROM
  63. 8000-FFFF   R       Fixed program ROM
  64.  
  65. Sound processor
  66. 0000-07ff   R/W     Z-page Working RAM
  67. 0800-083f   R/W     Custom I/O (Quad Pokey)
  68. 1000        W       IRQ Ack
  69. 1100        W       Speech Data
  70. 1200        W       Speech write strobe on
  71. 1300        W       Speech write strobe off
  72. 1400        W       Main CPU ack latch
  73. 1500        W       Bit 0 = Speech chip reset
  74. 1800        R       Main CPU comm latch
  75. 1C00        R       Bit 7 = Speech chip ready
  76. 1C01        R       Bit 7 = Sound CPU comm latch full flag
  77.             R       Bit 6 = Sound CPU ack latch full flag
  78. 8000-FFFF   R       Program ROM
  79.  
  80. ****************************************************************************/
  81.  
  82. #include "driver.h"
  83. #include "vidhrdw/generic.h"
  84.  
  85. /* sndhrdw jedi.c */
  86. WRITE_HANDLER( jedi_speech_w );
  87. READ_HANDLER( jedi_speech_ready_r );
  88.  
  89. /* vidhrdw jedi.c */
  90. WRITE_HANDLER( jedi_paletteram_w );
  91. WRITE_HANDLER( jedi_backgroundram_w );
  92. int  jedi_vh_start(void);
  93. void jedi_vh_stop(void);
  94. void jedi_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  95. WRITE_HANDLER( jedi_vscroll_w );
  96. WRITE_HANDLER( jedi_hscroll_w );
  97.  
  98. extern unsigned char *jedi_PIXIRAM;
  99. extern unsigned char *jedi_backgroundram;
  100. extern size_t jedi_backgroundram_size;
  101.  
  102. WRITE_HANDLER( jedi_soundlatch_w );
  103. WRITE_HANDLER( jedi_soundacklatch_w );
  104. READ_HANDLER( jedi_soundacklatch_r );
  105. READ_HANDLER( jedi_soundlatch_r );
  106. READ_HANDLER( jedi_soundstat_r );
  107. READ_HANDLER( jedi_mainstat_r );
  108. READ_HANDLER( jedi_control_r );
  109. WRITE_HANDLER( jedi_control_w );
  110. WRITE_HANDLER( jedi_alpha_banksel_w );
  111. WRITE_HANDLER( jedi_sound_reset_w );
  112. WRITE_HANDLER( jedi_rom_banksel_w );
  113.  
  114.  
  115.  
  116. static unsigned char *nvram;
  117. static size_t nvram_size;
  118.  
  119. static void nvram_handler(void *file, int read_or_write)
  120. {
  121.     if (read_or_write)
  122.         osd_fwrite(file,nvram,nvram_size);
  123.     else
  124.     {
  125.         if (file)
  126.             osd_fread(file,nvram,nvram_size);
  127.         else
  128.             memset(nvram,0,nvram_size);
  129.     }
  130. }
  131.  
  132.  
  133.  
  134. static struct MemoryReadAddress readmem[] =
  135. {
  136.     { 0x0000, 0x07ff, MRA_RAM },
  137.     { 0x0800, 0x08ff, MRA_RAM },
  138.     { 0x0C00, 0x0C00, input_port_0_r },
  139.     { 0x0C01, 0x0C01, jedi_mainstat_r }, /* IN1 */
  140.     { 0x1400, 0x1400, jedi_soundacklatch_r },
  141.     { 0x1800, 0x1800, jedi_control_r },
  142.     { 0x2000, 0x27FF, MRA_RAM },
  143.     { 0x2800, 0x2FFF, MRA_RAM },
  144.     { 0x3000, 0x37BF, MRA_RAM },
  145.     { 0x37C0, 0x3BFF, MRA_RAM },
  146.     { 0x4000, 0x7FFF, MRA_BANK1 },
  147.     { 0x8000, 0xFFFF, MRA_ROM },
  148.     { -1 }    /* end of table */
  149. };
  150.  
  151. static struct MemoryWriteAddress writemem[] =
  152. {
  153.     { 0x0000, 0x07ff, MWA_RAM },
  154.     { 0x0800, 0x08ff, MWA_RAM, &nvram, &nvram_size },
  155.     { 0x1C80, 0x1C82, jedi_control_w},
  156.     { 0x1D80, 0x1D80, watchdog_reset_w },
  157.     { 0x1E84, 0x1E84, jedi_alpha_banksel_w },
  158.     { 0x1E86, 0x1E86, jedi_sound_reset_w },
  159.     { 0x1F00, 0x1F00, jedi_soundlatch_w },
  160.     { 0x1F80, 0x1F80, jedi_rom_banksel_w },
  161.     { 0x2000, 0x27FF, jedi_backgroundram_w, &jedi_backgroundram, &jedi_backgroundram_size },
  162.     { 0x2800, 0x2FFF, jedi_paletteram_w, &paletteram },
  163.     { 0x3000, 0x37BF, videoram_w, &videoram, &videoram_size },
  164.     { 0x37C0, 0x3Bff, MWA_RAM, &spriteram, &spriteram_size },
  165.     { 0x3C00, 0x3C01, jedi_vscroll_w },
  166.     { 0x3D00, 0x3D01, jedi_hscroll_w },
  167.     { 0x3E00, 0x3FFF, MWA_RAM, &jedi_PIXIRAM },
  168.     { -1 }    /* end of table */
  169. };
  170.  
  171. static struct MemoryReadAddress readmem2[] =
  172. {
  173.     { 0x0000, 0x07FF, MRA_RAM },
  174.     { 0x0800, 0x080F, pokey1_r },
  175.     { 0x0810, 0x081F, pokey2_r },
  176.     { 0x0820, 0x082F, pokey3_r },
  177.     { 0x0830, 0x083F, pokey4_r },
  178.     { 0x1800, 0x1800, jedi_soundlatch_r },
  179.     { 0x1C00, 0x1C00, jedi_speech_ready_r },
  180.     { 0x1C01, 0x1C01, jedi_soundstat_r },
  181.     { 0x8000, 0xFFFF, MRA_ROM },
  182.     { -1 }    /* end of table */
  183. };
  184.  
  185. static struct MemoryWriteAddress writemem2[] =
  186. {
  187.     { 0x0000, 0x07FF, MWA_RAM },
  188.     { 0x0800, 0x080F, pokey1_w },
  189.     { 0x0810, 0x081F, pokey2_w },
  190.     { 0x0820, 0x082F, pokey3_w },
  191.     { 0x0830, 0x083F, pokey4_w },
  192.     { 0x1100, 0x13FF, jedi_speech_w },
  193.     { 0x1400, 0x1400, jedi_soundacklatch_w },
  194.     { -1 }    /* end of table */
  195. };
  196.  
  197.  
  198.  
  199. INPUT_PORTS_START( jedi )
  200.     PORT_START  /* IN0 */
  201.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON3 )
  202.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 )
  203.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 )
  204.     PORT_BIT (0x08, IP_ACTIVE_HIGH, IPT_UNUSED )
  205.     PORT_SERVICE( 0x10, IP_ACTIVE_LOW )
  206.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN3 )
  207.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN2 )
  208.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 )
  209.  
  210.     PORT_START  /* IN1 */
  211.     PORT_BIT( 0x03, IP_ACTIVE_HIGH, IPT_UNUSED )
  212.     PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_TILT )
  213.     PORT_BIT( 0x78, IP_ACTIVE_HIGH, IPT_UNUSED )
  214.     PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_VBLANK )
  215.  
  216.     PORT_START  /* IN2 */
  217.     PORT_ANALOG( 0xff, 0x80, IPT_AD_STICK_Y, 100, 10, 0, 255 )
  218.  
  219.     PORT_START  /* IN3 */
  220.     PORT_ANALOG( 0xff, 0x80, IPT_AD_STICK_X, 100, 10, 0, 255 )
  221. INPUT_PORTS_END
  222.  
  223.  
  224.  
  225. static struct GfxLayout charlayout =
  226. {
  227.     8,8,    /* 8*8 characters */
  228.     512,    /* 512 characters */
  229.     2,      /* 2 bits per pixel */
  230.     { 0, 1 }, /* the bitplanes are packed in one nibble */
  231.     { 0, 2, 4, 6, 8, 10, 12, 14 },
  232.     { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16 },
  233.     16*8   /* every char takes 16 consecutive bytes */
  234. };
  235.  
  236. static struct GfxLayout pflayout =
  237. {
  238.     16,16,    /* 16*16 characters (8x8 doubled) */
  239.     2048,    /* 2048 characters */
  240.     4,    /* 4 bits per pixel */
  241.     { 0, 4, 2048*16*8, 2048*16*8+4 },
  242.     { 0,0, 1,1, 2,2, 3,3, 8+0,8+0, 8+1,8+1, 8+2,8+2, 8+3,8+3 },
  243.     { 0*16,0*16, 1*16,1*16, 2*16,2*16, 3*16,3*16,
  244.             4*16,4*16, 5*16,5*16, 6*16,6*16, 7*16,7*16,
  245.             8*16,8*16, 9*16,9*16, 10*16,10*16, 11*16,11*16,
  246.             12*16,12*16, 13*16,13*16, 14*16,14*16, 15*16,15*16 },
  247.     16*8    /* every char takes 16 consecutive bytes */
  248. };
  249.  
  250. static struct GfxLayout spritelayout =
  251. {
  252.     8,16,    /* 8*16 sprites */
  253.     2048,    /* 2048 sprites */
  254.     4,    /* 4 bits per pixel */
  255.     { 0, 4, 2048*32*8, 2048*32*8+4 },
  256.     { 0, 1, 2, 3, 8+0, 8+1, 8+2, 8+3},
  257.     { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16,
  258.             8*16, 9*16, 10*16, 11*16, 12*16, 13*16, 14*16, 15*16 },
  259.     32*8    /* every sprite takes 32 consecutive bytes */
  260. };
  261.  
  262.  
  263. static struct GfxDecodeInfo gfxdecodeinfo[] =
  264. {
  265.     { REGION_GFX1, 0, &charlayout,    0, 1 },
  266.     { REGION_GFX2, 0, &pflayout,      0, 1 },
  267.     { REGION_GFX3, 0, &spritelayout,  0, 1 },
  268.     { -1 }
  269. };
  270.  
  271.  
  272.  
  273. static struct POKEYinterface pokey_interface =
  274. {
  275.     4,  /* 4 chips */
  276.     1500000,    /* 1.5 MHz? */
  277.     { 30, 30, MIXER(30,MIXER_PAN_LEFT), MIXER(30,MIXER_PAN_RIGHT) },
  278.     /* The 8 pot handlers */
  279.     { 0, 0 ,0 ,0},
  280.     { 0, 0 ,0 ,0},
  281.     { 0, 0 ,0 ,0},
  282.     { 0, 0 ,0 ,0},
  283.     { 0, 0 ,0 ,0},
  284.     { 0, 0 ,0 ,0},
  285.     { 0, 0 ,0 ,0},
  286.     { 0, 0 ,0 ,0},
  287.     /* The allpot handler */
  288.     { 0,0,0,0 }
  289. };
  290.  
  291. static struct TMS5220interface tms5220_interface =
  292. {
  293.     672000,     /* clock speed (80*samplerate) */
  294.     100,        /* volume */
  295.     0           /* IRQ handler */
  296. };
  297.  
  298.  
  299.  
  300. static struct MachineDriver machine_driver_jedi =
  301. {
  302.     /* basic machine hardware */
  303.     {
  304.         {
  305.             CPU_M6502,
  306.             2500000,    /* 2.5 Mhz */
  307.             readmem,writemem,0,0,
  308.             interrupt,4
  309.         },
  310.         {
  311.             CPU_M6502,
  312.             1500000,        /* 1.5 Mhz */
  313.             readmem2,writemem2,0,0,
  314.             interrupt,4
  315.         }
  316.     },
  317.     60, DEFAULT_REAL_60HZ_VBLANK_DURATION,   /* frames per second, vblank duration */
  318.     4,  /* 4 cycles per frame - enough for the two CPUs to properly synchronize */
  319.     0,
  320.  
  321.     /* video hardware */
  322.     37*8, 30*8, { 0*8, 37*8-1, 0*8, 30*8-1 },
  323.     gfxdecodeinfo,
  324.     1024,0,    /* no colortable, we do the lookups ourselves */
  325.     0,
  326.  
  327.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE,
  328.     0,
  329.     jedi_vh_start,
  330.     jedi_vh_stop,
  331.     jedi_vh_screenrefresh,
  332.  
  333.     /* sound hardware */
  334.     SOUND_SUPPORTS_STEREO,0,0,0,
  335.     {
  336.         {
  337.             SOUND_POKEY,
  338.             &pokey_interface
  339.         },
  340.         {
  341.             SOUND_TMS5220,
  342.             &tms5220_interface
  343.         }
  344.     },
  345.  
  346.     nvram_handler
  347. };
  348.  
  349.  
  350.  
  351. /***************************************************************************
  352.  
  353.   Game driver(s)
  354.  
  355. ***************************************************************************/
  356.  
  357. ROM_START( jedi )
  358.     ROM_REGION( 0x1C000, REGION_CPU1 )    /* 64k for code + 48k for banked ROMs */
  359.     ROM_LOAD( "14f_221.bin",  0x08000, 0x4000, 0x414d05e3 )
  360.     ROM_LOAD( "13f_222.bin",  0x0c000, 0x4000, 0x7b3f21be )
  361.     ROM_LOAD( "13d_123.bin",  0x10000, 0x4000, 0x877f554a )    /* Page 0 */
  362.     ROM_LOAD( "13b_124.bin",  0x14000, 0x4000, 0xe72d41db )    /* Page 1 */
  363.     ROM_LOAD( "13a_122.bin",  0x18000, 0x4000, 0xcce7ced5 )    /* Page 2 */
  364.  
  365.     ROM_REGION( 0x10000, REGION_CPU2 )    /* space for the sound ROMs */
  366.     ROM_LOAD( "01c_133.bin",  0x8000, 0x4000, 0x6c601c69 )
  367.     ROM_LOAD( "01a_134.bin",  0xC000, 0x4000, 0x5e36c564 )
  368.  
  369.     ROM_REGION( 0x02000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  370.     ROM_LOAD( "11t_215.bin",  0x00000, 0x2000, 0x3e49491f )    /* Alphanumeric */
  371.  
  372.     ROM_REGION( 0x10000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  373.     ROM_LOAD( "06r_126.bin",  0x00000, 0x8000, 0x9c55ece8 )    /* Playfield */
  374.     ROM_LOAD( "06n_127.bin",  0x08000, 0x8000, 0x4b09dcc5 )
  375.  
  376.     ROM_REGION( 0x20000, REGION_GFX3 | REGIONFLAG_DISPOSE )
  377.     ROM_LOAD( "01h_130.bin",  0x00000, 0x8000, 0x2646a793 )    /* Sprites */
  378.     ROM_LOAD( "01f_131.bin",  0x08000, 0x8000, 0x60107350 )
  379.     ROM_LOAD( "01m_128.bin",  0x10000, 0x8000, 0x24663184 )
  380.     ROM_LOAD( "01k_129.bin",  0x18000, 0x8000, 0xac86b98c )
  381.  
  382.     ROM_REGION( 0x0800, REGION_PROMS )    /* background smoothing */
  383.     ROM_LOAD( "136030.117",   0x0000, 0x0400, 0x9831bd55 )
  384.     ROM_LOAD( "136030.118",   0x0400, 0x0400, 0x261fbfe7 )
  385. ROM_END
  386.  
  387.  
  388.  
  389. GAMEX( 1984, jedi, 0, jedi, jedi, 0, ROT0, "Atari", "Return of the Jedi", GAME_NO_COCKTAIL )
  390.